package com.itheima.util;

import java.text.SimpleDateFormat;
import java.util.Date;

public class MyDateUtil {
    private MyDateUtil(){}
    public static String dateToString(Date date){
        return dateToString(date,null);
    }
    public static String dateToString(Date date,String pattern){
        if(pattern == null || "".equals(pattern)){
            pattern = "yyyy-MM-dd HH:mm:ss";
        }
        SimpleDateFormat format = new SimpleDateFormat(pattern);
        String s = format.format(date);
        return s;
    }
}
